package com.genius.mobile_page.jiekou.yundai.controller;

import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

import javax.annotation.Resource;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.other.entity.ResponseJson;
import com.genius.mobile_page.common.ErrorResponseData;
import com.genius.mobile_page.common.ResponseData;
import com.genius.mobile_page.jiekou.yundai.TripleDES;
import com.genius.mobile_page.jiekou.yundai.service.YundaiService;
import com.genius.mobile_page.pandian.service.PandianEveryService;
import com.genius.mobile_page.pandian.service.PandianService;
import com.genius.mobile_page.pingjia.service.PingjiaService;
import com.genius.mobile_page.siji.service.SijiqiandaoService;
import com.genius.workflow.log.ControllerLog;



@Controller
public class YundaiController {
	
	private Logger log = LoggerFactory.getLogger(YundaiController.class);
	@Autowired
    @Qualifier("yundaiService")
//	@Resource(name="PandianService")
	private YundaiService yundaiService;
    
	private String originKey = "123456";
	
   @ControllerLog(description="查询金虎云贷门店信息")
   @RequestMapping("/mobile_page/jiekou/yundai/getYundaiInfo")
   @ResponseBody
   public JSONObject getYundaiInfo(@RequestBody JSONObject parms){
   		log.info("查询金虎云贷门店信息请求--->"+parms);
   		JSONObject resData;
   		try {
   			TripleDES des = new TripleDES();
			String jiemi = des.desDecript(parms.getString("param"), originKey);
			log.info("查询金虎云贷门店信息解密后请求--->"+jiemi);
			resData = yundaiService.getYundaiInfo(JSONObject.parseObject(jiemi));
			
		} catch (InvalidKeyException | BadPaddingException | IllegalBlockSizeException | NoSuchPaddingException
				| NoSuchAlgorithmException | UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			resData = new JSONObject();
			resData.put("ret", "2");
			resData.put("msg", "您没有权限访问");
//			resData = new ErrorResponseData("参数解密失败，原因："+e.getMessage());
		}
   		log.info("查询金虎云贷门店信息返回值--->"+resData);
       return resData;
   	}
}

